<!DOCTYPE html>
<meta charset="UTF-8">
<div style="height: 320px;"><br>
			<form action="" method="post" class="col-md-6 col-md-offset-3">
				<div class="input-group">
					<span class="input-group-addon">原密码</span>
					<input type="password" class="form-control" id="pad" onchange="fun(this.value);" placeholder="原密码">
				</div>
				<div>
					<label id="pad-error" class="error col-lg-offset-3" for="pad"></label>
				</div><br>
				<div class="input-group">
					<span class="input-group-addon">新密码</span>
					<input type="password" class="form-control" id="pad1" placeholder="新密码">
				</div>
				<div><label id="pad1-error" class="error col-lg-offset-3" for="pad1"></label></div><br>
				<div class="input-group">
					<span class="input-group-addon">请确认密码</span>
					<input type="password" class="form-control" id="pad2" placeholder="确认密码">
				</div>
				<div><label id="pad2-error" class="error col-lg-offset-3" for="pad2"></label></div><br>
				<center><button type="button" id = "btn_1" class="btn btn-primary" style="width:200px;">确定</button></center>
			</form>
		</div>
	</div>
<script type="text/javascript">
function fun(str){
	$.post('../enduser/pwd', {password: str}, function(data){
		if(!data){
		$("#pad-error").html("原密码输入错误");
		}else {
			$("#pad-error").html("");
		}
	});
}

$("#btn_1").click(function(){
	var pad1 = $("#pad1").val();
	var pad2 = $("#pad2").val();
	var str = $("#pad").val();
	var f = false;
	if(str == "" || str == null){
		f = true;
		$("#pad-error").html("请输入原密码");
	}else if(pad1 == "" || pad1 == null){
		f = true;
		$("#pad1-error").html("请输入密码");
	}else if(pad2 == "" || pad2 == null){
		f = true;
		$("#pad1-error").html("");
		$("#pad2-error").html("请确认密码");
	}else if(pad1 != pad2){
		f = true;
		$("#pad1-error").html("");
		$("#pad2-error").html("两次密码不一致");
	}
	
	if(!f){
		$.post('../enduser/pwd', {password: str}, function(data){
			if(data){
				alert("密码修改成功!请重新登陆!");
				window.parent.location="../enduser/xg?pad="+pad1;
			}
		});	
	}
});
</script>